package com.pajk.user.api.http;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.pajk.test.api.BaseTest;
import com.pajk.test.client.ContextHelper;
import com.pingan.jk.api.request.ApiCode;
import com.pingan.jk.api.request.User_Login;
import com.pingan.jk.api.resp.Api_USER_LoginResp;
import com.pingan.jk.client.ApiContext;
import com.pingan.jk.client.BaseRequest;

public class User_LoginIT extends BaseTest{
	
	@Test(description="user.login 用户静态密码登录 SecurityType.RegisteredDevice")
	public void loginTest() throws Exception{
		ApiContext context = super.registerDevice();
		
		String mobile = "13840868525";
		String md5Passwd = getUploadPassword("123456");
		User_Login req = new User_Login(mobile, md5Passwd);
		ContextHelper.sendRequest(context, new BaseRequest[] { req });
		Assert.assertEquals(req.getReturnCode() , ApiCode.SUCCESS);
		
		Api_USER_LoginResp res = req.getResponse();
		Assert.assertNotNull(res);
		System.out.println(res.expire);
		System.out.println(res.token);
		System.out.println(res.uid);
		//
	}

//	// 2.1 输入不存在mobile
//	User_Login req2 = new User_Login("11000000000", "password");
//	ContextHelper.sendRequest(context, new BaseRequest[] { req2 });
//	Assert.assertEquals(ApiCode.USER_NOT_FOUND_1003020, req2.getReturnCode());
//
//	// 2.2 用户名密码错误
//	User_Login req3 = new User_Login("13000000000", "password");
//	ContextHelper.sendRequest(context, new BaseRequest[] { req3 });
//	Assert.assertEquals(ApiCode.USERNAME_OR_PASSWORD_ERROR_1003010,
//			req3.getReturnCode());

}
